package 代码记录.指定公司代码练习记录.华为_2024.分值100;

import java.util.Scanner;

/**
 * @author zx
 * @create 2024-02-02 20:07
 * 自己没做出来，人家的好的做法；思路很简单
 */
public class 分割均衡字符串_26 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String str = sc.next();
            int res = balancedStringSplit(str);
            System.out.println(res);
        }
        sc.close();
    }

    public static int balancedStringSplit(String s) {
        int count = 0;
        int balance = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'X') {
                balance++;
            } else {
                balance--;
            }
            if (balance == 0) {
                count++;
            }
        }
        return count;
    }
}
